package com.yang.modules.common.interceptor;

import com.yang.common.core.util.MdcUtil;
import feign.RequestInterceptor;
import feign.RequestTemplate;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @author: Billyang
 * @date: 2024/9/15 23:08
 */
@Component
@Slf4j
public class FeignHeaderInterceptor implements RequestInterceptor {
    @Override
    public void apply(RequestTemplate requestTemplate) {
        String traceId = MdcUtil.get();
        log.info("FeignHeaderInterceptor traceId:{}",traceId);
        requestTemplate.header(MdcUtil.UNIQUE_KEY, traceId);
    }
}
